package com.martin.lib_base.ktx

/**
 * 分割列表
 */
fun <T> List<T>.split(size: Int): List<List<T>> {
    val lists = arrayListOf<List<T>>()
    if (this.isNotEmpty()) {
        for (i in 0..this.size step size) {
            val subList = this.subList(i, (i + size).coerceAtMost(this.size))
            if (subList.isNotEmpty()) {
                lists.add(subList)
            }
        }
    }
    return lists
}